package golf;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import database.DAO;

/*
 * MODELNO	NUMBER(38,0)
MODELNM	VARCHAR2(20 BYTE)
MODELSEX	CHAR(1 BYTE)
MODELHEIGHT	NUMBER(38,0)
MODELDESC	VARCHAR2(100 BYTE)
MODELBASICPROPNO	NUMBER(38,0)
 */
public class Model {
	public static char MAN = 'M';
	public static char WOMEN = 'F';
	int no;
	String name;
	char sex;
	int height;
	String description;
	int prop_no;
	Property property;
	
	public Model(){}
	/*
	 * MODELNO	NUMBER(38,0)
MODELNM	VARCHAR2(20 BYTE)
MODELSEX	CHAR(1 BYTE)
MODELHEIGHT	NUMBER(38,0)
MODELDESC	VARCHAR2(100 BYTE)
MODELBASICPROPNO	NUMBER(38,0)
	 */
	public Model(ResultSet rs){
		try {
			setNo( rs.getInt("MODELNO") );
			setName(rs.getString("MODELNM"));
			setSex(rs.getString("MODELSEX").charAt(0));
			setHeight(rs.getInt("MODELHEIGHT"));
			setDescription(rs.getString("MODELDESC"));
			
			
			setProp_no(rs.getInt("MODELBASICPROPNO"));
			
			PreparedStatement pstmt = DAO.getInstance().getConnection().prepareStatement("select * from PROPERTY where PROPNO=?");
			pstmt.setInt(1, getProp_no());
			ResultSet rs2 = pstmt.executeQuery();
			if( rs2.next() ) property = new Property(rs2);
			rs2.close();
			pstmt.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public Property getProperty() {
		return property;
	}
	public void setProperty(Property property) {
		this.property = property;
	}
	public int getNo() {
		return no;
	}
	public void setNo(int no) {
		this.no = no;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public char getSex() {
		return sex;
	}
	public void setSex(char sex) {
		this.sex = sex;
	}
	public int getHeight() {
		return height;
	}
	public void setHeight(int height) {
		this.height = height;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public int getProp_no() {
		return prop_no;
	}
	public void setProp_no(int prop_no) {
		this.prop_no = prop_no;
	}
	
	
}
